function validateChallengeNewForm(form){
    var errorList = new Array();

    var title = form['title'].value;
    var description = form['description'].value;
    var solution = form['solution'].value;
    var category = parseInt(form['category'].value);
    var src = form['file'].value;
    var extensions = form['extensions'].value;

    if (!title) {
        errorList.push('Empty title');
        fieldHighlight(form['title'], true);
    }
    
    if (!category) {
        errorList.push('Select a category');
        fieldHighlight(form['category'], true);
    }
    
    if (!description) {
        errorList.push('Empty description');
        fieldHighlight(form['description'], true);
    }
    
    if (!solution) {
        errorList.push('Empty solution');
        fieldHighlight(form['solution'], true);
    }
    
    if (src != "") {
        var format = src.substring(src.length - 3);
        var expresionsArray = extensions.split(", ");
        var allowed = false;
        for (var i = 0; i < expresionsArray.length; i++) 
        {
         if (expresionsArray[i] == format) {
         allowed = true;
         break;
         }
        }
        if (!allowed)
            errorList.push('Only ' + extensions + ' file extensions are accepted for upload');
    }
    
    if (errorList.length > 0) {
        showErrorList(errorList);
        return false;
    } else {
        return true;
    }
}

function toggleCategoryView(category)
{
    var id = $(category).attr("id").split('-')[1];
    var obj = $("#group-" + id);
    
    if(obj.css("display") == "none")
    {
        obj.slideDown(500);
        changeCheck(id,'-');
    }
    else
    {
        obj.slideUp(500);
        changeCheck(id,'+');
    }
}

function changeCheck(id,text)
{
    var span = document.getElementById("check-"+id); 
    span.innerHTML = text;
}